
/**
 * 游戏数据
 */


class Data  {

    // 游戏是否开始
    public _started: Boolean = false

    // 当前为第几关
    public _level: number = 1
    public _historyTop: number = 1 // 历史最高

    // 切换场景时 跳王的位置和速度 和方向
    public _x: number = 290
    public _y: number = 930
    public _vx: number = 0
    public _vy: number = 0
    public _dir: boolean = false // true 为右

 }

 // 数据代理
 let onWatch = (obj, setBind, getLogger) => {
    let handler = {
      get(target, property, receiver) {
        getLogger(target, property)
        return Reflect.get(target, property, receiver)
      },
      set(target, property, value, receiver) {
        setBind(value, property)
        return Reflect.set(target, property, value)
      }
    }
    return new Proxy(obj, handler)
  }

  let obj = new Data()
  let proxy = onWatch(
    obj,
    (v, property) => {
        Laya.stage && Laya.stage.event("datachange" + property, v)
    },
    (target, property) => {
      
    }
  )
  export default proxy